import { produce } from 'immer';

const immer = (createState) => {
  return (set, get, api) => {
    api.setState = (fn) => {
      console.log('setState', fn);
      return set(produce(fn));
    };

    return createState(api.setState, get, api);
  };
};

export default immer;
